<extend name="layout/edit" />

<block name="HEADER">
   
</block>

<block name="CONTENT">
    <control:form id="form"/>
</block>

<block name="FOOTER">
   <script type="text/javascript">
    var  page=(function(ns){
    	
    	ns.init = function(){
    		if(window.__mode==2){ ns.setSeq(); }
    		if(window.__mode==3){ $("#btnSave").hide(); }
    		form.on("input","type",function(){
    			ns.setSeq(2);
    		});
    	}
    	
    	//设置必填
    	ns.setSeq=function(mode){
    		var type = form.getValue('type');
			if(  type == 'miniprogram' ){
				form.setReq("appid,pagepath,url",true);  
			}else if( type == "多级菜单类型" ){
				form.setReq("appid,pagepath,event_key,url",false);  
			}else if( type == "click" ){
				form.setReq("event_key,url",false);  
				form.setReq("event_key",true); 
				!form.getValue("event_key") && form.setValue("event_key",'MENU_KEY_NEWS'); 
			}else{
				form.setReq("url",true);  
				form.setReq("appid,pagepath,event_key",false);  
			}
    	}
    	
        //保存
        ns.save=function(){
            form.save(1).then(function(res){
            	if($.getRequest("type")=="2"){
            		form.opener.grid2.load();
            	}else{
            		form.opener.grid.load();
            	}
            });
        }
        
        return ns;
    }({}));
    
    $(function(){ page.init(); });
   </script>
</block>



